﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace INSTA.MusiqueStore.UI.Web1
{
    public partial class MyMusic : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

            //Image1.ImageUrl = "img/Bob_Marley-Legend.jpg";
            ////Image1.Attributes.Add("onmouseover", "DivMain.style='background-image:url('" + Image1.ImageUrl + "')");
            //Image1.Attributes.Add("onmouseover", "changeBackground('DivMain','DivSubMain','" + Image1.ImageUrl + "');");
            //Image2.ImageUrl = "img/Stromae-Racine_Carree.jpg";
            ////Image1.Attributes.Add("onmouseover", "DivMain.style='background-image:url('" + Image1.ImageUrl + "')");
            //Image2.Attributes.Add("onmouseover", "changeBackground('DivMain','DivSubMain','" + Image2.ImageUrl + "');");
            Table1.Rows.Add(new TableRow());
            AddMyAlbums();

        }

        private void AddMyAlbums()
        {
            var a = INSTA.MusiqueStore.DAL.CustomMusiqueStoreEntities.GetMyAlbums((int)Session["idClient"]);

            foreach (var album in a)
            {

                var p = new Panel
                {
                    Width = 150,
                    CssClass = "divAlbum"
                };
                var p2 = new Panel
                {
                    Width = 150,
                    CssClass = "divAlbum"
                };
                var l = new Label
                {
                    Text = album.Nom + "<br/>" + album.Piste.First().Artiste.NomComplet,
                    CssClass = "labelAlbum"
                };
                var i = new ImageButton()
                            {
                                Height = 150,
                                Width = 150,
                                PostBackUrl = "Details.aspx?i=" + album.Id,
                                ImageUrl = Properties.Settings.Default.COVERPATH + album.LienPochette
                            };

                i.Attributes.Add("onmouseover", "changeBackground('DivSubMain','" + i.ImageUrl + "');");
                p.Controls.Add(i);
                p2.Controls.Add(l);
                var c = new TableCell { CssClass = "pochette" };
                c.Controls.Add(p);
                c.Controls.Add(p2);
                Table1.Rows[0].Cells.Add(c);

            }

        }

        }
}